//
//  FirstLevelViewController.m
//  TestTable
//
//  Created by wp w on 12-5-24.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "FirstLevelViewController.h"
#import "OnlyTextViewController.h"
#import "OnlyImageViewController.h"
#import "ImageTextViewController.h"
#import "StyleSubtitleViewController.h"
#import "StyleValue1ViewController.h"
#import "StyleValue2ViewController.h"
#import "IndentationLeaveViewController.h"
#import "CustomCellViewController.h"
#import "CustomCellViewController2.h"
#import "SectionsViewController.h"

@implementation FirstLevelViewController
@synthesize listData;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title = @"table view";
    
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [array addObject:@"onlyText"];
    [array addObject:@"onlyImage"];
    [array addObject:@"imageText"];
    [array addObject:@"StyleSubtitle"];
    [array addObject:@"StyleValue1"];
    [array addObject:@"StyleValue2"];
    [array addObject:@"IndentationLeave"];
    [array addObject:@"CustomCell"];
	[array addObject:@"CustomCell2"];
    [array addObject:@"Sections"];
    
    self.listData =array;
    [array release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.listData = nil;
}

-(void)dealloc
{
    [listData release];
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark -
#pragma mark Table Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView 
 numberOfRowsInSection:(NSInteger)section
{
    return [self.listData count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView 
        cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellTableIdentifier = @"FirstLevelViewController";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
                             CellTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier: CellTableIdentifier] autorelease];
    }
        
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
    return cell;
}


#pragma mark -
#pragma mark Table Delegate Methods
- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger row = [indexPath row];
    NSString *title = [listData objectAtIndex:row];
    if (kCFCompareEqualTo == [title compare:@"onlyText"]) {
        UIViewController *contoller = [[[OnlyTextViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];                                    
    }
    else if (kCFCompareEqualTo == [title compare:@"onlyImage"]) {
        UIViewController *contoller = [[[OnlyImageViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"imageText"]) {
        UIViewController *contoller = [[[ImageTextViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"StyleSubtitle"]) {
        UIViewController *contoller = [[[StyleSubtitleViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"StyleValue1"]) {
        UIViewController *contoller = [[[StyleValue1ViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"StyleValue2"]) {
        UIViewController *contoller = [[[StyleValue2ViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"IndentationLeave"]) {
        UIViewController *contoller = [[[IndentationLeaveViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"CustomCell"]) {
        UIViewController *contoller = [[[CustomCellViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
	else if (kCFCompareEqualTo == [title compare:@"CustomCell2"]) {
        UIViewController *contoller = [[[CustomCellViewController2 alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else if (kCFCompareEqualTo == [title compare:@"Sections"]) {
        UIViewController *contoller = [[[SectionsViewController alloc] init] autorelease];
        [self.navigationController pushViewController:contoller animated:YES];  
    }
    else {
        
    }
}


@end
